package com.example.test.config;

import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;

import javax.servlet.MultipartConfigElement;

/**
 * @ClassName: 林文峰
 * @Author Administrator
 * @Date 2020/6/18 0018
 */
@Configuration
public class FileUploadConfig {

	@Bean
	public MultipartConfigElement multipartConfigElement(){
		MultipartConfigFactory factory = new MultipartConfigFactory();
		//设置单个文件最大上传容量
		factory.setMaxFileSize(DataSize.ofKilobytes(1024L));
		//设置所有文件最大上传容量
		factory.setMaxRequestSize(DataSize.ofMegabytes(500L));
		return factory.createMultipartConfig();

	}
}
